﻿@using Resources
@model NetSurveillance.WebApp.Models.IMDataSearchModel
@{
    ViewBag.Title = "即时聊天数据查询";
    Layout = "~/Views/Shared/_SimpleLayout.cshtml";
}
<div class="showdia_qq_content">
    <div class="showdia_qq_left">
        <div class="showdia_qq_left_title">
            @ViewResource.HostListTitle
        </div>
        <div class="showdia_qq_left_tree">
            @Html.Partial("../Host/_HostTree", ViewBag.TreeNode as string)
        </div>
    </div>
    @using (Html.BeginForm())
    {
        @Html.ValidationSummary()
        <div class="showdia_complex_middle">
            <div class="showdialog_complex_middle_title">
                &nbsp;&nbsp;筛选字段
            </div>
            @Html.HiddenFor(m => m.Id, new { id = "txt_imSearchId" })
            <ul class="showdia_complex_middle_ul">
                <li>
                    <dl class="showdia_complex_middle_dl">
                        <dt>协议类型</dt>
                        <dd>
                            <div class="complex_select_border01">
                                @Html.DropDownListFor(m => m.Protocol, ViewBag.Protocols as SelectList, 
                                                      Resource.DropdownList_Select,new { id = "ddl_jkxy" })
                            </div>
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl class="showdia_complex_middle_dl">
                        <dt>聊天内容</dt>
                        <dd>
                            <div class="complex_select_bordertxt1">
                                @Html.TextBoxFor(m => m.Content, new { id = "txt_imSearch_content" })
                            </div>
                            @Html.ValidationMessageFor(m => m.Content)
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl class="showdia_complex_middle_dl">
                        <dt>时间</dt>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.StartDate)</div>
                            <div class="complex_select_border02">
                                @Html.TextBox("StartDate",
                                              Model != null && Model.StartDate.HasValue?string.Format("{0:yyyy-MM-dd}",Model.StartDate):null, 
                                              new { id = "txt_imSearch_startDate", @readonly = "readonly" })
                            </div>
                            @Html.ValidationMessageFor(m => m.StartDate)
                        </dd>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.EndDate)</div>
                            <div class="complex_select_border02">
                                @Html.TextBox("EndDate",
                                              Model != null && Model.EndDate.HasValue?string.Format("{0:yyyy-MM-dd}",Model.EndDate):null,
                                              new { id = "txt_imSearch_endDate", @readonly = "readonly" })
                            </div>
                            @Html.ValidationMessageFor(m => m.EndDate)
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl class="showdia_complex_middle_dl">
                        <dt>账号</dt>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.Account)</div>
                            <div class="complex_select_border02">
                                @Html.DropDownListFor(m => m.Account, ViewBag.LocalAccts as SelectList, 
                                                      Resource.DropdownList_Select, new { id = "sl_imSearch_account" })
                            </div>
                            @Html.ValidationMessageFor(m => m.Account)
                        </dd>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.TheOtherAccount)</div>
                            <div class="complex_select_border02">
                                @Html.DropDownListFor(m=>m.TheOtherAccount,ViewBag.RemoteAccts as SelectList,
                                                      Resource.DropdownList_Select, new { id = "sl_imSearch_theOtherAccount" })
                            </div>
                            @Html.ValidationMessageFor(m => m.TheOtherAccount)
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl class="showdia_complex_middle_dl">
                        <dt>计算机地址</dt>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.IP)</div>
                            <div class="complex_select_border02">
                                @Html.TextBoxFor(m => m.IP, new { id = "txt_imSearch_ip" })
                            </div>
                            @Html.ValidationMessageFor(m => m.IP)
                        </dd>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.Mac)</div>
                            <div class="complex_select_border02">
                                @Html.TextBoxFor(m => m.Mac, new { id = "txt_imSearch_mac" })
                            </div>
                            @Html.ValidationMessageFor(m => m.Mac)
                        </dd>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.RemoteIP)</div>
                            <div class="complex_select_border02">
                                @Html.TextBoxFor(m => m.RemoteIP, new { id = "txt_imSearch_remoteIp" })
                            </div>
                            @Html.ValidationMessageFor(m => m.RemoteIP)
                        </dd>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.RemoteMac)</div>
                            <div class="complex_select_border02">
                                @Html.TextBoxFor(m => m.RemoteMac, new { id = "txt_imSearch_remoteMac" })
                            </div>
                            @Html.ValidationMessageFor(m => m.RemoteMac)
                        </dd>
                    </dl>
                </li>
                <li>
                    <dl class="showdia_complex_middle_dl">
                        <dt>下载/上传文件名称</dt>
                        <dd>
                            <div class="showdia_complex_middle_dl_text">@Html.LabelFor(m => m.FileName)</div>
                            <div class="complex_select_border02">
                                @Html.TextBoxFor(m => m.FileName, new { id = "txt_imSearch_fileName" })
                            </div>
                            @Html.ValidationMessageFor(m => m.FileName)
                        </dd>
                    </dl>
                </li>
            </ul>

        </div> 
        <dl class="showdia_complex_right">
            @Html.Action("CheckQueryLists", "Search", new { type = "imSearch" })
        </dl> 
        <div class="showdia_qq_bottom">
            <div class="showdia_complex_bottom_btns">
                <ul class="config_bottom_btndivs03">
                    <li>
                        <input type="button" id="btn_showdia_complex_submit" value="提交查询" /></li>
                    <li>
                        <input type="submit" id="btn_showdia_complex_save" value="保存查询" /></li>
                    <li>
                        <input type="reset" id="btn_showdia_complex_reset" value="重置查询" /></li>
                    <li>
                        <input type="button" id="btn_showdia_complex_cancel" value="@Resource.Button_Exit" /></li>
                </ul>
            </div>
        </div>
    }
</div>
@section javascript
{
    <script type="text/javascript">
        $(function() {
            $(".showdialog_qq_tab tr:even").css("background", "#fff");
            $('#ddSelect dd label').live('click', function() {
                var $dd = $(this).parent(), searchId = $dd.attr('data-entryId');
                window.location.href = '@Url.Action("IMSearch")' + '?imSearchId=' + searchId + '&__randomDate=' + (new Date()).getTime();
                return false;
            });

            $("#chk_showdialog_complex_right_selectall").bind("change", function() {
                $("#ddSelect>dd>input:checkbox").attr("checked", $(this).is(':checked'));
            });

            $("#btn_showdialog_complex_right_del").bind("click", function() {
                var arr = new Array();
                $('#ddSelect input[name="searchCondirion"]:checked').each(function(index, item) {
                    arr.push(item.value);
                });
                var ids = arr.join(",");
                if (!ids) {
                    alert("请选择要删除的查询条件!");
                    return;
                }
                $.showLoading('Deleting now,please wait');
                $.ajax({
                    url: '@Url.Action("DeleteSearch")',
                    type: 'post',
                    dataType: 'json',
                    data: { searchIds: ids },
                    success: function(result) {
                        if (result.Success) {
                            $(arr).each(function(index, item) {
                                $('#ddSelect dd[data-entryId=' + item + ']').remove();
                                $("#chk_showdialog_complex_right_selectall").attr("checked", false);
                            });
                        } else {
                            alert(result.Message);
                        }
                        $.hideLoading();
                    }
                });
            });
            var datepickerOpts = {
                dateFormat: 'yy-m-dd',
                showMonthAfterYear: true,
                constrainInput: true,
                changeMonth: true,
                changeYear: true,
                autoSize: false,
                showButtonPanel: true
            };
            $("#txt_imSearch_startDate,#txt_imSearch_endDate").datepicker(datepickerOpts);
            $('#btn_showdia_complex_cancel').click(windowClose);
            $('#btn_showdia_complex_submit').click(imSubmitQuery);
        });

        function imSubmitQuery() {
            var entry = {};
            entry.Protocol = $("#ddl_jkxy").val().trim();
            entry.Content = $('#txt_imSearch_content').val().trim();
            entry.StartDate = $('#txt_imSearch_startDate').val();
            entry.EndDate = $("#txt_imSearch_endDate").val();
            entry.Account = $('#sl_imSearch_account').val();
            entry.TheOtherAccount = $('#sl_imSearch_theOtherAccount').val();
            entry.FileName = $('#txt_imSearch_fileName').val();
            entry.Id = $('#txt_imSearchId').val();
            entry.HostIds = getCheckHostIds();
            var seachUrl = "@Url.Action("IMSearchResult")",
                params = $.param(entry, true);
            seachUrl = seachUrl + "?" + params;
            (window.opener || window.dialogArguments).location.href = seachUrl;
            window.close();
        }

        function windowClose() {
            if (!window.confirm('@MessageResource.ExitConfirm')) return;
            window.close();
        }
    </script>
}
